<?php

use Faker\Factory as Faker;
use App\Models\Identification;
use App\Repositories\IdentificationRepository;

trait MakeIdentificationTrait
{
    /**
     * Create fake instance of Identification and save it in database
     *
     * @param array $identificationFields
     * @return Identification
     */
    public function makeIdentification($identificationFields = [])
    {
        /** @var IdentificationRepository $identificationRepo */
        $identificationRepo = App::make(IdentificationRepository::class);
        $theme = $this->fakeIdentificationData($identificationFields);
        return $identificationRepo->create($theme);
    }

    /**
     * Get fake instance of Identification
     *
     * @param array $identificationFields
     * @return Identification
     */
    public function fakeIdentification($identificationFields = [])
    {
        return new Identification($this->fakeIdentificationData($identificationFields));
    }

    /**
     * Get fake data of Identification
     *
     * @param array $postFields
     * @return array
     */
    public function fakeIdentificationData($identificationFields = [])
    {
        $fake = Faker::create();

        return array_merge([
            'name' => $fake->word,
            'phone' => $fake->word,
            'identity_card' => $fake->word,
            'bank_card' => $fake->word,
            'validity2_res' => $fake->word,
            'validity4_res' => $fake->word,
            'user_id' => $fake->randomDigitNotNull,
            'validity' => $fake->randomDigitNotNull,
            'created_at' => $fake->word,
            'updated_at' => $fake->word
        ], $identificationFields);
    }
}
